/**
 * Created by yihua on 2017/1/8.
 */


$(document).ready(function(){
    var btn = $("#login");
    btn.click(function(){
        var user = $("#username").val();
        var password = $("#password").val();
        $.ajax({
            url : '/home/login',
            timeout : 100000,
            type : 'post',
            dataType : 'json',
            data : {
                username : user,
                password : password,
            },
            success : function (rs) {
                if (rs.errno != 0) {
                    toastr.error('登录失败：'+rs.errmsg, '', {positionClass: 'toast-bottom-center'});
                    return true;
                }
                location.href="/home/index"
                //btn.attr('href','/home/index');
            },
            error : function () {
                $('.loading-gif-father').css('display', 'none');
                alert('系统异常，请稍候再试');
            }
        });
        //alert(test);
    });
    return true;

});
    /*
function login(){
    var btn = $("#login");
    btn.click(function(){
        //var test = $("#username").val();
        //alert(test);
        alert('Hello!');
    });
    return true;

    var params = WST.getParams('.ipt');
    params.typ = typ;
    if(!$('#loginName').isValid())return;
    if(!$('#loginPwd').isValid())return;
    if(!$('#verifyCode').isValid())return;
    $.post(WST.U('home/users/checkLogin'),params,function(data,textStatus){
        var json = WST.toJson(data);
        if(json.status=='1'){
            if(typ==2){
                location.href=WST.U('home/homepage');
            }else if(typ==1){
                location.href=WST.U('home/users/index');
            }else{
                location.reload();
            }
        }else{
            WST.msg(json.msg, {icon: 5});
            WST.getVerify('#verifyImg');
        }
    });
    */